﻿@{
    ViewBag.Title = "AddFile";
    Layout = "~/Views/Shared/_LayoutUser.cshtml";
}

<div class="container inner">

    <div class="row content settings">
        <div class="col-lg-12">
            <ul class="nav nav-tabs" id="settingsTab">
                <li class="active"><a href="#addfile" onclick="ShowAddFile()"><i class="fa fa-bars">
                </i>Add File</a></li>
                <li><a href="#addtext" onclick="ShowAddText()"><i class="fa fa-globe"></i>Add Text</a></li>
            </ul>
            @using (Html.BeginForm("ProcessSubmit", "Files", FormMethod.Post, new { id = "uploadForm", enctype = "multipart/form-data" }))
            {     
                <div class="tab-content">
                    <p>
                    </p>
                    @(Html.Telerik().DropDownList()
                        .Name("ddlFields")
                        .DataBinding(binding => binding.Ajax().Select("_SelectFields", "Files"))
                        .Placeholder("Select a field")
                    )
                    <div class="tab-pane active" id="addfile">
                        @(Html.Telerik().Upload().Name("attachments")
                        .ClientEvents(e => e.OnSelect("attachments_OnSelect")))
                        <p class="note">
                            Maximum combined file size: 10 MB
                        </p>
                    </div>
                    <div class="tab-pane" id="addtext">
                        File Name: @Html.TextBox("txtFileName")
                        @( Html.Telerik().Editor()
                            .Name("editorAddText")
                            .HtmlAttributes(new { style = "height:100px;" })
                            .Encode(false)
                            .Tools(tools => tools
                            .Clear().Bold().Italic().Underline().Separator().CreateLink().Unlink())
                        )
                    </div>
                    Key words:
                    @Html.Hidden("txtType", "0")
                    @( Html.Telerik().Editor()
                        .Name("keyWords")
                        .HtmlAttributes(new { style = "height:100px;width:350px;" })
                        .Encode(false)
                        .Tools(tools => tools
                        .Clear())
                    )
                    @ViewData["error"]
                    <br />
                    @ViewData["errorDetails"] 
                    <div class="form">
                        <div class="form-group">
                            <div class="col-sm-offset-0 col-sm-10">
                                <button type="submit" class="btn btn-primary" >
                                    Save as PDF</button>
                            </div>
                        </div>
                    </div>
                    @*<div style="margin: 20px 0 0 0;">
                        <input type="submit" value="Save as PDF" class="t-button" />
                        <input type="reset" value="Cancel" class="t-button" />
                    </div>*@
                </div>
            }
        </div>
    </div>
</div>
<script type="text/javascript">

    $(document).ready(function () {
        $(".t-upload-button span").text("Select a file");

    });

    function attachments_OnSelect(e) {
        setTimeout("changeRemoveButton", 100);
    }

    function changeRemoveButton() {
        $(".t-upload-action").html("<span class='t-icon t-delete'></span> Delete");
    }

    function ShowAddFile() {
        //$("#dvShowAddText").hide("slow");
        //$("#dvShowAddFile").show("slow");
        // $("#editorAddText").data("tDropDownList").text("");
        $("#editorAddText").data("tEditor").value('');
        $("#txtFileName").val('');
        $("#txtType").val("0");
    }

    function ShowAddText() {
        //$("#dvShowAddText").show("slow");
        //$("#dvShowAddFile").hide("slow");
        $("#txtType").val("1");
    }
   
</script>
